package com.commerce.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.commerce.view.R;

import java.util.List;

public class MyGridAdapter extends BaseAdapter {
    List<String> list;
    Context context;
    public MyGridAdapter(Context context, List<String> list) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if(view==null){
            view = LayoutInflater.from(context).inflate(R.layout.layout_view,viewGroup,false);
            viewHolder = new ViewHolder();
            viewHolder.textView = view.findViewById(R.id.vw_tv_test);
            view.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) view.getTag();
        }
        viewHolder.textView.setVisibility(View.VISIBLE);
        viewHolder.textView.setText(list.get(i));
        return view;
    }

    class ViewHolder{
        TextView textView;
    }
}
